﻿Imports Telerik.Web.UI

Partial Class Menu
    Inherits System.Web.UI.Page


    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Me.Theme = GetGlobalResourceObject("SystemResource", "Theme")
    End Sub


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Session("UserInfo") Is Nothing Then
            Response.Redirect("~/login.aspx")
        Else
            Dim SESCLASS As New SessionClass
            SESCLASS = Session("UserInfo")

            Dim id As String = SESCLASS.getUserID

            odsMenu.SelectParameters("ID").DefaultValue = id

        End If

    End Sub


    Protected Sub rmMain_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs)

        'If Not (e.Item.Text = "Tools") And Not (e.Item.Text = "Logout") Then
        '    e.Item.Attributes.Add("href", "#")
        'End If

        If (e.Item.Value = "Tools") Then
            'e.Item.Attributes.Add("href", "#")
            e.Item.PostBack = False
        End If

        If (e.Item.Value = "Home") Then
            e.Item.NavigateUrl = "~/Default.aspx"
            'e.Item.PostBack = False
        End If

        If (e.Item.Value = "Logout") Then
            e.Item.ImageUrl = "~/Design/Logout-Gray.png"
            e.Item.CssClass = "LogoutImage"
        End If
    End Sub

    Protected Sub rmMain_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs)

        Dim MenuSelectedItemstr As String
        MenuSelectedItemstr = e.Item.Value

        Dim langAr As String = "ar-JO"
        Dim langEn As String = "En-GB"

        'Dim url As String = Request.AppRelativeCurrentExecutionFilePath

        If Not (Request.Cookies("Language") Is Nothing) AndAlso Not (Request.Cookies("Language").Value Is Nothing) Then

            If MenuSelectedItemstr = "Logout" Then
                FormsAuthentication.SignOut()
                Session.Clear()
                Response.Redirect("~/login.aspx")
            End If

        End If
    End Sub

End Class
